package com.woniu.lottery.controller;

import com.wn.www.common.entity.dto.LotteryActivityDto;
import com.wn.www.common.result.Result;
import com.woniu.lottery.entity.LotteryActivity;
import com.woniu.lottery.entity.LotteryPrize;
import com.woniu.lottery.entity.LotteryResult;
import com.woniu.lottery.service.ILotteryActivityService;
import com.woniu.lottery.service.ILotteryPrizeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author mane
 * @since 2025-04-13
 */

@RestController
@RequestMapping("/lottery-activity")
public class LotteryActivityController {

    @Autowired
    private ILotteryActivityService lotteryActivityService;

    /**
     * 抽奖入口
     * @param userId
     * @param activityId
     * @return
     */
    @PostMapping("/lottery/participate")
    public Result<LotteryResult> participate(
            @RequestParam("userId") Long userId,
            @RequestParam("activityId") Long activityId){
        LotteryResult lotteryResult = lotteryActivityService.participate(userId, activityId);
        return Result.ok(lotteryResult);
    }

    @PostMapping("/add")
    public Result addLotteryActivity(LotteryActivityDto lotteryActivityDto){
        String str = lotteryActivityService.addLotteryActivity(lotteryActivityDto);
        return new Result(200,str,null);
    }

}
